<?php
/**
 * Created by PhpStorm.
 * User: td
 * Date: 15/3/4
 * Time: 下午10:54
 */

namespace Home\Controller;
use Think\Controller;

class TimeController extends Controller {

    public function timeUpdateMission(){
        $mission_db = D('Mission');
        $mission_result = $mission_db->setMissionUpdate();
        $time = date('Y-m-d H:i:s',time());
        echo $time.","."刷新任务表一次！";
        echo '<br>';
    }

    public function sendMessage(){
        $message_db = D('Message');
        $message_result = $message_db->getPhones();
        //dump($message_result);
        if(is_array($message_result)){
            foreach($message_result as $message_result_one){
                //发送短信通知
                $phone = $message_result_one['phone'];
                $url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
                $post_data = "account=cf_gwhz&password=XLyxR3&mobile=".$phone."&content=".rawurlencode("您好，您的项目有新的乙方进行申请，请及时登录活控（ihuokong.com）查看具体消息。");
                $result = xml_to_array(post($post_data,$url));
                //dump($result);
            }
            $time = date('Y-m-d H:i:s',time());
            echo $time.","."甲方提醒消息发送成功!";
            print_r($message_result);
            echo '<br>';
        }else{
            $time = date('Y-m-d H:i:s',time());
            echo $time.","."无甲方有提醒消息!！";
            echo '<br>';
        }
    }

    public function noReadMessage(){
        $message_db = D('Message');
        $message_result = $message_db->getNoReadMessagePhone();
        //dump($message_result);
        if(is_array($message_result)){
            foreach($message_result as $message_result_one){
                //发送短信通知
                $phone = $message_result_one['phone'];
                $url = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
                $post_data = "account=cf_gwhz&password=XLyxR3&mobile=".$phone."&content=".rawurlencode("您好，您有新的消息留言，是关于接活找活的哦，请及时登录活控（ihuokong.com）查看具体消息。");
                $result = xml_to_array(post($post_data,$url));
                //dump($result);
            }
            $time = date('Y-m-d H:i:s',time());
            echo $time.","."有未读消息提醒发送成功!";
            print_r($message_result);
            echo '<br>';
        }else{
            $time = date('Y-m-d H:i:s',time());
            echo $time.","."无用户有未读消息!！";
            echo '<br>';
        }
    }

} 